import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
function getDefaultCity(){
  var defaultCity;
  if(localStorage.getItem('city')){
    defaultCity = localStorage.getItem('city')
  }else{
    defaultCity = '武汉'
  }
  return defaultCity
}
export default new Vuex.Store({
  state: {
    city:getDefaultCity()
  },
  mutations: {
    changeStateCity(state,city){
      state.city = city
    }
  },
  actions: {
    changeCity(ctx,val){
      ctx.commit('changeStateCity',val)
    }
  },
  modules: {
  }
})
